package com.mallotec.android.timenote.viewmodel.factory;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.mallotec.android.timenote.data.repository.TimenoteRepository;
import com.mallotec.android.timenote.viewmodel.TimenoteListViewModel;

/**
 * @author reborn
 * @program TimeNote
 * @description
 * @create 2020-10-28 02:05
 **/
public class TimenoteListModelFactory extends ViewModelProvider.NewInstanceFactory {

    private TimenoteRepository repository;

    public TimenoteListModelFactory(@NonNull TimenoteRepository repository) {
        super();
        this.repository = repository;
    }

    @NonNull
    @Override
    @SuppressWarnings("unchecked")
    public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
        return (T) new TimenoteListViewModel(repository);
    }
}
